﻿{include file="Public:meta"}

<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 精华分享管理 <span class="c-gray en">&gt;</span> 精华分享列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="{:url('add')}" class="btn btn-primary radius">
				<i class="Hui-iconfont">&#xe600;</i> 添加精华分享
			</a>
		</span> 
	</div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">列表</th>
			</tr>
			<tr class="text-c">
				<!-- <th width="25"><input type="checkbox" name="" value=""></th> -->
				<th width="40">ID</th>
				<th width="150">标题</th>
				<th width="90">作者</th>
				<th width="130">添加时间</th>
				<th width="100">是否显示</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
        	{foreach name="list" item="v" key="k"}
				<tr class="text-c">
					<!-- <td><input type="checkbox" value="1" name=""></td> -->
					<td>{$v.id}</td>
					<td>{$v.title}</td>
					<td>{$v.author}</td>
					<td>{$v.create_time|date="Y-m-d H:i:s",###}</td>
					<td class="td-status">
						{if $v.is_show == 0}
							<span onClick="doShow(this,'{$v.id}',1)" class="label radius">隐藏中</span>
						{else}
							<span onClick="doShow(this,'{$v.id}',0)" class="label label-success radius">显示中</span>
						{/if}
					</td>
					<td class="td-manage">
						<a title="编辑" href="javascript:;" onclick="edit('{$v.id}')" class="ml-5" style="text-decoration:none">
							<i class="Hui-iconfont" style="font-size:20px;">&#xe6df;</i>
						</a> 
						{if $v.is_del == 0}
						<a title="" href="javascript:;" onclick="doDel(this,'{$v.id}')" class="ml-4" style="text-decoration:none">
							<i class="Hui-iconfont" style="font-size:20px;">&#xe6e2;</i>
						</a>
						{else}
							<span class="label radius">已删除</span>
						{/if}
					</td>
				</tr>
			{/foreach}
		</tbody>
	</table>
</div>
<!--_footer 作为公共模版分离出去-->
{include file="Public:footer"}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/../Admin/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="__STATIC__/../Admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="__STATIC__/../Admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

function edit(id){
	location.href = "{:url('edit')}?id="+id;
}


/*文章-删除*/
function doDel(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '{:url("edit")}',
			data:{id:id,is_del:1},
			dataType: 'json',
			success: function(data){
				// $(obj).parents("tr").remove();
				layer.msg(data.msg,{icon:1,time:1000});

				// 页面刷新
				location.replace(location.href);
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

/*文章-停用*/
function doShow(obj,id,is_show){
	$.ajax({
		type: 'POST',
		url: '{:url("edit")}',
		data:{id:id,is_show:is_show},
		dataType: 'json',
		success: function(data){
			layer.msg(data.msg,{icon:1,time:1000});

			// 页面刷新
			location.replace(location.href);
		},
		error:function(data) {
			console.log(data.msg);
		},
	});	

}

</script>
</body>
</html>